<?php

// Global variable for table object
$artista = NULL;

//
// Table class for artista
//
class cartista extends cTable {
	var $ArtistaId;
	var $ArtistaRubro;
	var $ArtistaSubRubro;
	var $ArtistaNombre;
	var $ArtistaFoto;
	var $ArtistaBio;
	var $ArtistaCV;
	var $ArtistaTel;
	var $ArtistaEmail;
	var $ArtistaFace;
	var $ArtistaWeb;
	var $ArtistaDireccion;
	var $ArtistaLocalidad;
	var $ArtistaProvincia;
	var $ArtistaPais;
	var $ArtistaActivo;

	//
	// Table class constructor
	//
	function __construct() {
		global $Language;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();
		$this->TableVar = 'artista';
		$this->TableName = 'artista';
		$this->TableType = 'TABLE';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
		$this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
		$this->ExportPageSize = "a4"; // Page size (PDF only)
		$this->DetailAdd = FALSE; // Allow detail add
		$this->DetailEdit = FALSE; // Allow detail edit
		$this->DetailView = FALSE; // Allow detail view
		$this->ShowMultipleDetails = FALSE; // Show multiple details
		$this->GridAddRowCount = 5;
		$this->AllowAddDeleteRow = ew_AllowAddDeleteRow(); // Allow add/delete row
		$this->UserIDAllowSecurity = 0; // User ID Allow
		$this->BasicSearch = new cBasicSearch($this->TableVar);

		// ArtistaId
		$this->ArtistaId = new cField('artista', 'artista', 'x_ArtistaId', 'ArtistaId', '`ArtistaId`', '`ArtistaId`', 3, -1, FALSE, '`ArtistaId`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->ArtistaId->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ArtistaId'] = &$this->ArtistaId;

		// ArtistaRubro
		$this->ArtistaRubro = new cField('artista', 'artista', 'x_ArtistaRubro', 'ArtistaRubro', '`ArtistaRubro`', '`ArtistaRubro`', 3, -1, FALSE, '`ArtistaRubro`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->ArtistaRubro->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ArtistaRubro'] = &$this->ArtistaRubro;

		// ArtistaSubRubro
		$this->ArtistaSubRubro = new cField('artista', 'artista', 'x_ArtistaSubRubro', 'ArtistaSubRubro', '`ArtistaSubRubro`', '`ArtistaSubRubro`', 3, -1, FALSE, '`ArtistaSubRubro`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->ArtistaSubRubro->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ArtistaSubRubro'] = &$this->ArtistaSubRubro;

		// ArtistaNombre
		$this->ArtistaNombre = new cField('artista', 'artista', 'x_ArtistaNombre', 'ArtistaNombre', '`ArtistaNombre`', '`ArtistaNombre`', 200, -1, FALSE, '`ArtistaNombre`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaNombre'] = &$this->ArtistaNombre;

		// ArtistaFoto
		$this->ArtistaFoto = new cField('artista', 'artista', 'x_ArtistaFoto', 'ArtistaFoto', '`ArtistaFoto`', '`ArtistaFoto`', 200, -1, TRUE, '`ArtistaFoto`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaFoto'] = &$this->ArtistaFoto;

		// ArtistaBio
		$this->ArtistaBio = new cField('artista', 'artista', 'x_ArtistaBio', 'ArtistaBio', '`ArtistaBio`', '`ArtistaBio`', 201, -1, FALSE, '`ArtistaBio`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaBio'] = &$this->ArtistaBio;

		// ArtistaCV
		$this->ArtistaCV = new cField('artista', 'artista', 'x_ArtistaCV', 'ArtistaCV', '`ArtistaCV`', '`ArtistaCV`', 200, -1, TRUE, '`ArtistaCV`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaCV'] = &$this->ArtistaCV;

		// ArtistaTel
		$this->ArtistaTel = new cField('artista', 'artista', 'x_ArtistaTel', 'ArtistaTel', '`ArtistaTel`', '`ArtistaTel`', 200, -1, FALSE, '`ArtistaTel`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaTel'] = &$this->ArtistaTel;

		// ArtistaEmail
		$this->ArtistaEmail = new cField('artista', 'artista', 'x_ArtistaEmail', 'ArtistaEmail', '`ArtistaEmail`', '`ArtistaEmail`', 200, -1, FALSE, '`ArtistaEmail`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaEmail'] = &$this->ArtistaEmail;

		// ArtistaFace
		$this->ArtistaFace = new cField('artista', 'artista', 'x_ArtistaFace', 'ArtistaFace', '`ArtistaFace`', '`ArtistaFace`', 200, -1, FALSE, '`ArtistaFace`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaFace'] = &$this->ArtistaFace;

		// ArtistaWeb
		$this->ArtistaWeb = new cField('artista', 'artista', 'x_ArtistaWeb', 'ArtistaWeb', '`ArtistaWeb`', '`ArtistaWeb`', 200, -1, FALSE, '`ArtistaWeb`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaWeb'] = &$this->ArtistaWeb;

		// ArtistaDireccion
		$this->ArtistaDireccion = new cField('artista', 'artista', 'x_ArtistaDireccion', 'ArtistaDireccion', '`ArtistaDireccion`', '`ArtistaDireccion`', 200, -1, FALSE, '`ArtistaDireccion`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaDireccion'] = &$this->ArtistaDireccion;

		// ArtistaLocalidad
		$this->ArtistaLocalidad = new cField('artista', 'artista', 'x_ArtistaLocalidad', 'ArtistaLocalidad', '`ArtistaLocalidad`', '`ArtistaLocalidad`', 200, -1, FALSE, '`ArtistaLocalidad`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaLocalidad'] = &$this->ArtistaLocalidad;

		// ArtistaProvincia
		$this->ArtistaProvincia = new cField('artista', 'artista', 'x_ArtistaProvincia', 'ArtistaProvincia', '`ArtistaProvincia`', '`ArtistaProvincia`', 200, -1, FALSE, '`ArtistaProvincia`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaProvincia'] = &$this->ArtistaProvincia;

		// ArtistaPais
		$this->ArtistaPais = new cField('artista', 'artista', 'x_ArtistaPais', 'ArtistaPais', '`ArtistaPais`', '`ArtistaPais`', 200, -1, FALSE, '`ArtistaPais`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['ArtistaPais'] = &$this->ArtistaPais;

		// ArtistaActivo
		$this->ArtistaActivo = new cField('artista', 'artista', 'x_ArtistaActivo', 'ArtistaActivo', '`ArtistaActivo`', '`ArtistaActivo`', 3, -1, FALSE, '`ArtistaActivo`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->ArtistaActivo->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ArtistaActivo'] = &$this->ArtistaActivo;
	}

	// Single column sort
	function UpdateSort(&$ofld) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sSortField = $ofld->FldExpression;
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
			$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
		} else {
			$ofld->setSort("");
		}
	}

	// Current detail table name
	function getCurrentDetailTable() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE];
	}

	function setCurrentDetailTable($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE] = $v;
	}

	// Get detail url
	function GetDetailUrl() {

		// Detail url
		$sDetailUrl = "";
		if ($this->getCurrentDetailTable() == "obras") {
			$sDetailUrl = $GLOBALS["obras"]->GetListUrl() . "?showmaster=" . $this->TableVar;
			$sDetailUrl .= "&ObraArtista=" . $this->ArtistaId->CurrentValue;
		}
		if ($sDetailUrl == "") {
			$sDetailUrl = "artistalist.php";
		}
		return $sDetailUrl;
	}

	// Table level SQL
	function SqlFrom() { // From
		return "`artista`";
	}

	function SqlSelect() { // Select
		return "SELECT * FROM " . $this->SqlFrom();
	}

	function SqlWhere() { // Where
		$sWhere = "";
		$this->TableFilter = "";
		ew_AddFilter($sWhere, $this->TableFilter);
		return $sWhere;
	}

	function SqlGroupBy() { // Group By
		return "";
	}

	function SqlHaving() { // Having
		return "";
	}

	function SqlOrderBy() { // Order By
		return "";
	}

	// Check if Anonymous User is allowed
	function AllowAnonymousUser() {
		switch (@$this->PageID) {
			case "add":
			case "register":
			case "addopt":
				return FALSE;
			case "edit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return FALSE;
			case "delete":
				return FALSE;
			case "view":
				return FALSE;
			case "search":
				return FALSE;
			default:
				return FALSE;
		}
	}

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		return $sFilter;
	}

	// Check if User ID security allows view all
	function UserIDAllow($id = "") {
		$allow = EW_USER_ID_ALLOW;
		switch ($id) {
			case "add":
			case "copy":
			case "gridadd":
			case "register":
			case "addopt":
				return (($allow & 1) == 1);
			case "edit":
			case "gridedit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return (($allow & 4) == 4);
			case "delete":
				return (($allow & 2) == 2);
			case "view":
				return (($allow & 32) == 32);
			case "search":
				return (($allow & 64) == 64);
			default:
				return (($allow & 8) == 8);
		}
	}

	// Get SQL
	function GetSQL($where, $orderby) {
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$where, $orderby);
	}

	// Table SQL
	function SQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$sFilter, $sSort);
	}

	// Table SQL with List page filter
	function SelectSQL() {
		$sFilter = $this->getSessionWhere();
		ew_AddFilter($sFilter, $this->CurrentFilter);
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(), $this->SqlGroupBy(),
			$this->SqlHaving(), $this->SqlOrderBy(), $sFilter, $sSort);
	}

	// Get ORDER BY clause
	function GetOrderBy() {
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql("", "", "", "", $this->SqlOrderBy(), "", $sSort);
	}

	// Try to get record count
	function TryGetRecordCount($sSql) {
		global $conn;
		$cnt = -1;
		if ($this->TableType == 'TABLE' || $this->TableType == 'VIEW') {
			$sSql = "SELECT COUNT(*) FROM" . preg_replace('/^SELECT\s([\s\S]+)?\*\sFROM/i', "", $sSql);
			$sOrderBy = $this->GetOrderBy();
			if (substr($sSql, strlen($sOrderBy) * -1) == $sOrderBy)
				$sSql = substr($sSql, 0, strlen($sSql) - strlen($sOrderBy)); // Remove ORDER BY clause
		} else {
			$sSql = "SELECT COUNT(*) FROM (" . $sSql . ") EW_COUNT_TABLE";
		}
		if ($rs = $conn->Execute($sSql)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// Get record count based on filter (for detail record count in master table pages)
	function LoadRecordCount($sFilter) {
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $sFilter;
		$this->Recordset_Selecting($this->CurrentFilter);

		//$sSql = $this->SQL();
		$sSql = $this->GetSQL($this->CurrentFilter, "");
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $this->LoadRs($this->CurrentFilter)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Get record count (for current List page)
	function SelectRecordCount() {
		global $conn;
		$origFilter = $this->CurrentFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SelectSQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $conn->Execute($sSql)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Update Table
	var $UpdateTable = "`artista`";

	// INSERT statement
	function InsertSQL(&$rs) {
		global $conn;
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]))
				continue;
			$names .= $this->fields[$name]->FldExpression . ",";
			$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		while (substr($names, -1) == ",")
			$names = substr($names, 0, -1);
		while (substr($values, -1) == ",")
			$values = substr($values, 0, -1);
		return "INSERT INTO " . $this->UpdateTable . " ($names) VALUES ($values)";
	}

	// Insert
	function Insert(&$rs) {
		global $conn;
		return $conn->Execute($this->InsertSQL($rs));
	}

	// UPDATE statement
	function UpdateSQL(&$rs, $where = "") {
		$sql = "UPDATE " . $this->UpdateTable . " SET ";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]))
				continue;
			$sql .= $this->fields[$name]->FldExpression . "=";
			$sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		while (substr($sql, -1) == ",")
			$sql = substr($sql, 0, -1);
		$filter = $this->CurrentFilter;
		ew_AddFilter($filter, $where);
		if ($filter <> "")	$sql .= " WHERE " . $filter;
		return $sql;
	}

	// Update
	function Update(&$rs, $where = "", $rsold = NULL) {
		global $conn;
		return $conn->Execute($this->UpdateSQL($rs, $where));
	}

	// DELETE statement
	function DeleteSQL(&$rs, $where = "") {
		$sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
		if ($rs) {
			if (array_key_exists('ArtistaId', $rs))
				ew_AddFilter($where, ew_QuotedName('ArtistaId') . '=' . ew_QuotedValue($rs['ArtistaId'], $this->ArtistaId->FldDataType));
		}
		$filter = $this->CurrentFilter;
		ew_AddFilter($filter, $where);
		if ($filter <> "")
			$sql .= $filter;
		else
			$sql .= "0=1"; // Avoid delete
		return $sql;
	}

	// Delete
	function Delete(&$rs, $where = "") {
		global $conn;
		return $conn->Execute($this->DeleteSQL($rs, $where));
	}

	// Key filter WHERE clause
	function SqlKeyFilter() {
		return "`ArtistaId` = @ArtistaId@";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		if (!is_numeric($this->ArtistaId->CurrentValue))
			$sKeyFilter = "0=1"; // Invalid key
		$sKeyFilter = str_replace("@ArtistaId@", ew_AdjustSql($this->ArtistaId->CurrentValue), $sKeyFilter); // Replace key value
		return $sKeyFilter;
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "artistalist.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// List URL
	function GetListUrl() {
		return "artistalist.php";
	}

	// View URL
	function GetViewUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("artistaview.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("artistaview.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Add URL
	function GetAddUrl() {
		return "artistaadd.php";
	}

	// Edit URL
	function GetEditUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("artistaedit.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("artistaedit.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Inline edit URL
	function GetInlineEditUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
	}

	// Copy URL
	function GetCopyUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("artistaadd.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("artistaadd.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Inline copy URL
	function GetInlineCopyUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
	}

	// Delete URL
	function GetDeleteUrl() {
		return $this->KeyUrl("artistadelete.php", $this->UrlParm());
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		if (!is_null($this->ArtistaId->CurrentValue)) {
			$sUrl .= "ArtistaId=" . urlencode($this->ArtistaId->CurrentValue);
		} else {
			return "javascript:alert(ewLanguage.Phrase('InvalidRecord'));";
		}
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&amp;ordertype=" . $fld->ReverseSort());
			return ew_CurrentPage() . "?" . $sUrlParm;
		} else {
			return "";
		}
	}

	// Get record keys from $_POST/$_GET/$_SESSION
	function GetRecordKeys() {
		global $EW_COMPOSITE_KEY_SEPARATOR;
		$arKeys = array();
		$arKey = array();
		if (isset($_POST["key_m"])) {
			$arKeys = ew_StripSlashes($_POST["key_m"]);
			$cnt = count($arKeys);
		} elseif (isset($_GET["key_m"])) {
			$arKeys = ew_StripSlashes($_GET["key_m"]);
			$cnt = count($arKeys);
		} elseif (isset($_GET)) {
			$arKeys[] = @$_GET["ArtistaId"]; // ArtistaId

			//return $arKeys; // Do not return yet, so the values will also be checked by the following code
		}

		// Check keys
		$ar = array();
		foreach ($arKeys as $key) {
			if (!is_numeric($key))
				continue;
			$ar[] = $key;
		}
		return $ar;
	}

	// Get key filter
	function GetKeyFilter() {
		$arKeys = $this->GetRecordKeys();
		$sKeyFilter = "";
		foreach ($arKeys as $key) {
			if ($sKeyFilter <> "") $sKeyFilter .= " OR ";
			$this->ArtistaId->CurrentValue = $key;
			$sKeyFilter .= "(" . $this->KeyFilter() . ")";
		}
		return $sKeyFilter;
	}

	// Load rows based on filter
	function &LoadRs($sFilter) {
		global $conn;

		// Set up filter (SQL WHERE clause) and get return SQL
		//$this->CurrentFilter = $sFilter;
		//$sSql = $this->SQL();

		$sSql = $this->GetSQL($sFilter, "");
		$rs = $conn->Execute($sSql);
		return $rs;
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->ArtistaId->setDbValue($rs->fields('ArtistaId'));
		$this->ArtistaRubro->setDbValue($rs->fields('ArtistaRubro'));
		$this->ArtistaSubRubro->setDbValue($rs->fields('ArtistaSubRubro'));
		$this->ArtistaNombre->setDbValue($rs->fields('ArtistaNombre'));
		$this->ArtistaFoto->Upload->DbValue = $rs->fields('ArtistaFoto');
		$this->ArtistaBio->setDbValue($rs->fields('ArtistaBio'));
		$this->ArtistaCV->Upload->DbValue = $rs->fields('ArtistaCV');
		$this->ArtistaTel->setDbValue($rs->fields('ArtistaTel'));
		$this->ArtistaEmail->setDbValue($rs->fields('ArtistaEmail'));
		$this->ArtistaFace->setDbValue($rs->fields('ArtistaFace'));
		$this->ArtistaWeb->setDbValue($rs->fields('ArtistaWeb'));
		$this->ArtistaDireccion->setDbValue($rs->fields('ArtistaDireccion'));
		$this->ArtistaLocalidad->setDbValue($rs->fields('ArtistaLocalidad'));
		$this->ArtistaProvincia->setDbValue($rs->fields('ArtistaProvincia'));
		$this->ArtistaPais->setDbValue($rs->fields('ArtistaPais'));
		$this->ArtistaActivo->setDbValue($rs->fields('ArtistaActivo'));
	}

	// Render list row values
	function RenderListRow() {
		global $conn, $Security, $gsLanguage;

		// Call Row Rendering event
		$this->Row_Rendering();

   // Common render codes
		// ArtistaId
		// ArtistaRubro
		// ArtistaSubRubro
		// ArtistaNombre
		// ArtistaFoto
		// ArtistaBio
		// ArtistaCV
		// ArtistaTel
		// ArtistaEmail
		// ArtistaFace
		// ArtistaWeb
		// ArtistaDireccion
		// ArtistaLocalidad
		// ArtistaProvincia
		// ArtistaPais
		// ArtistaActivo
		// ArtistaId

		$this->ArtistaId->ViewValue = $this->ArtistaId->CurrentValue;
		$this->ArtistaId->ViewCustomAttributes = "";

		// ArtistaRubro
		if (strval($this->ArtistaRubro->CurrentValue) <> "") {
			$sFilterWrk = "`RubroId`" . ew_SearchString("=", $this->ArtistaRubro->CurrentValue, EW_DATATYPE_NUMBER);
		$sSqlWrk = "SELECT `RubroId`, `RubroNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `rubros`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->ArtistaRubro, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->ArtistaRubro->ViewValue = $rswrk->fields('DispFld');
				$rswrk->Close();
			} else {
				$this->ArtistaRubro->ViewValue = $this->ArtistaRubro->CurrentValue;
			}
		} else {
			$this->ArtistaRubro->ViewValue = NULL;
		}
		$this->ArtistaRubro->ViewCustomAttributes = "";

		// ArtistaSubRubro
		if (strval($this->ArtistaSubRubro->CurrentValue) <> "") {
			$sFilterWrk = "`SubRubroId`" . ew_SearchString("=", $this->ArtistaSubRubro->CurrentValue, EW_DATATYPE_NUMBER);
		$sSqlWrk = "SELECT `SubRubroId`, `SubRubroNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `subrubro`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->ArtistaSubRubro, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
		$sSqlWrk .= " ORDER BY `SubRubroNombre`";
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->ArtistaSubRubro->ViewValue = $rswrk->fields('DispFld');
				$rswrk->Close();
			} else {
				$this->ArtistaSubRubro->ViewValue = $this->ArtistaSubRubro->CurrentValue;
			}
		} else {
			$this->ArtistaSubRubro->ViewValue = NULL;
		}
		$this->ArtistaSubRubro->ViewCustomAttributes = "";

		// ArtistaNombre
		$this->ArtistaNombre->ViewValue = $this->ArtistaNombre->CurrentValue;
		$this->ArtistaNombre->ViewCustomAttributes = "";

		// ArtistaFoto
		if (!ew_Empty($this->ArtistaFoto->Upload->DbValue)) {
			$this->ArtistaFoto->ViewValue = $this->ArtistaFoto->Upload->DbValue;
		} else {
			$this->ArtistaFoto->ViewValue = "";
		}
		$this->ArtistaFoto->ViewCustomAttributes = "";

		// ArtistaBio
		$this->ArtistaBio->ViewValue = $this->ArtistaBio->CurrentValue;
		$this->ArtistaBio->ViewCustomAttributes = "";

		// ArtistaCV
		if (!ew_Empty($this->ArtistaCV->Upload->DbValue)) {
			$this->ArtistaCV->ViewValue = $this->ArtistaCV->Upload->DbValue;
		} else {
			$this->ArtistaCV->ViewValue = "";
		}
		$this->ArtistaCV->ViewCustomAttributes = "";

		// ArtistaTel
		$this->ArtistaTel->ViewValue = $this->ArtistaTel->CurrentValue;
		$this->ArtistaTel->ViewCustomAttributes = "";

		// ArtistaEmail
		$this->ArtistaEmail->ViewValue = $this->ArtistaEmail->CurrentValue;
		$this->ArtistaEmail->ViewCustomAttributes = "";

		// ArtistaFace
		$this->ArtistaFace->ViewValue = $this->ArtistaFace->CurrentValue;
		$this->ArtistaFace->ViewCustomAttributes = "";

		// ArtistaWeb
		$this->ArtistaWeb->ViewValue = $this->ArtistaWeb->CurrentValue;
		$this->ArtistaWeb->ViewCustomAttributes = "";

		// ArtistaDireccion
		$this->ArtistaDireccion->ViewValue = $this->ArtistaDireccion->CurrentValue;
		$this->ArtistaDireccion->ViewCustomAttributes = "";

		// ArtistaLocalidad
		$this->ArtistaLocalidad->ViewValue = $this->ArtistaLocalidad->CurrentValue;
		$this->ArtistaLocalidad->ViewCustomAttributes = "";

		// ArtistaProvincia
		$this->ArtistaProvincia->ViewValue = $this->ArtistaProvincia->CurrentValue;
		$this->ArtistaProvincia->ViewCustomAttributes = "";

		// ArtistaPais
		$this->ArtistaPais->ViewValue = $this->ArtistaPais->CurrentValue;
		$this->ArtistaPais->ViewCustomAttributes = "";

		// ArtistaActivo
		if (strval($this->ArtistaActivo->CurrentValue) <> "") {
			switch ($this->ArtistaActivo->CurrentValue) {
				case $this->ArtistaActivo->FldTagValue(1):
					$this->ArtistaActivo->ViewValue = $this->ArtistaActivo->FldTagCaption(1) <> "" ? $this->ArtistaActivo->FldTagCaption(1) : $this->ArtistaActivo->CurrentValue;
					break;
				default:
					$this->ArtistaActivo->ViewValue = $this->ArtistaActivo->CurrentValue;
			}
		} else {
			$this->ArtistaActivo->ViewValue = NULL;
		}
		$this->ArtistaActivo->ViewCustomAttributes = "";

		// ArtistaId
		$this->ArtistaId->LinkCustomAttributes = "";
		$this->ArtistaId->HrefValue = "";
		$this->ArtistaId->TooltipValue = "";

		// ArtistaRubro
		$this->ArtistaRubro->LinkCustomAttributes = "";
		$this->ArtistaRubro->HrefValue = "";
		$this->ArtistaRubro->TooltipValue = "";

		// ArtistaSubRubro
		$this->ArtistaSubRubro->LinkCustomAttributes = "";
		$this->ArtistaSubRubro->HrefValue = "";
		$this->ArtistaSubRubro->TooltipValue = "";

		// ArtistaNombre
		$this->ArtistaNombre->LinkCustomAttributes = "";
		$this->ArtistaNombre->HrefValue = "";
		$this->ArtistaNombre->TooltipValue = "";

		// ArtistaFoto
		$this->ArtistaFoto->LinkCustomAttributes = "";
		$this->ArtistaFoto->HrefValue = "";
		$this->ArtistaFoto->HrefValue2 = $this->ArtistaFoto->UploadPath . $this->ArtistaFoto->Upload->DbValue;
		$this->ArtistaFoto->TooltipValue = "";

		// ArtistaBio
		$this->ArtistaBio->LinkCustomAttributes = "";
		$this->ArtistaBio->HrefValue = "";
		$this->ArtistaBio->TooltipValue = "";

		// ArtistaCV
		$this->ArtistaCV->LinkCustomAttributes = "";
		$this->ArtistaCV->HrefValue = "";
		$this->ArtistaCV->HrefValue2 = $this->ArtistaCV->UploadPath . $this->ArtistaCV->Upload->DbValue;
		$this->ArtistaCV->TooltipValue = "";

		// ArtistaTel
		$this->ArtistaTel->LinkCustomAttributes = "";
		$this->ArtistaTel->HrefValue = "";
		$this->ArtistaTel->TooltipValue = "";

		// ArtistaEmail
		$this->ArtistaEmail->LinkCustomAttributes = "";
		$this->ArtistaEmail->HrefValue = "";
		$this->ArtistaEmail->TooltipValue = "";

		// ArtistaFace
		$this->ArtistaFace->LinkCustomAttributes = "";
		$this->ArtistaFace->HrefValue = "";
		$this->ArtistaFace->TooltipValue = "";

		// ArtistaWeb
		$this->ArtistaWeb->LinkCustomAttributes = "";
		$this->ArtistaWeb->HrefValue = "";
		$this->ArtistaWeb->TooltipValue = "";

		// ArtistaDireccion
		$this->ArtistaDireccion->LinkCustomAttributes = "";
		$this->ArtistaDireccion->HrefValue = "";
		$this->ArtistaDireccion->TooltipValue = "";

		// ArtistaLocalidad
		$this->ArtistaLocalidad->LinkCustomAttributes = "";
		$this->ArtistaLocalidad->HrefValue = "";
		$this->ArtistaLocalidad->TooltipValue = "";

		// ArtistaProvincia
		$this->ArtistaProvincia->LinkCustomAttributes = "";
		$this->ArtistaProvincia->HrefValue = "";
		$this->ArtistaProvincia->TooltipValue = "";

		// ArtistaPais
		$this->ArtistaPais->LinkCustomAttributes = "";
		$this->ArtistaPais->HrefValue = "";
		$this->ArtistaPais->TooltipValue = "";

		// ArtistaActivo
		$this->ArtistaActivo->LinkCustomAttributes = "";
		$this->ArtistaActivo->HrefValue = "";
		$this->ArtistaActivo->TooltipValue = "";

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
	}

	// Export data in HTML/CSV/Word/Excel/Email/PDF format
	function ExportDocument(&$Doc, &$Recordset, $StartRec, $StopRec, $ExportPageType = "") {
		if (!$Recordset || !$Doc)
			return;

		// Write header
		$Doc->ExportTableHeader();
		if ($Doc->Horizontal) { // Horizontal format, write header
			$Doc->BeginExportRow();
			if ($ExportPageType == "view") {
				if ($this->ArtistaId->Exportable) $Doc->ExportCaption($this->ArtistaId);
				if ($this->ArtistaRubro->Exportable) $Doc->ExportCaption($this->ArtistaRubro);
				if ($this->ArtistaSubRubro->Exportable) $Doc->ExportCaption($this->ArtistaSubRubro);
				if ($this->ArtistaNombre->Exportable) $Doc->ExportCaption($this->ArtistaNombre);
				if ($this->ArtistaFoto->Exportable) $Doc->ExportCaption($this->ArtistaFoto);
				if ($this->ArtistaBio->Exportable) $Doc->ExportCaption($this->ArtistaBio);
				if ($this->ArtistaCV->Exportable) $Doc->ExportCaption($this->ArtistaCV);
				if ($this->ArtistaTel->Exportable) $Doc->ExportCaption($this->ArtistaTel);
				if ($this->ArtistaEmail->Exportable) $Doc->ExportCaption($this->ArtistaEmail);
				if ($this->ArtistaFace->Exportable) $Doc->ExportCaption($this->ArtistaFace);
				if ($this->ArtistaWeb->Exportable) $Doc->ExportCaption($this->ArtistaWeb);
				if ($this->ArtistaDireccion->Exportable) $Doc->ExportCaption($this->ArtistaDireccion);
				if ($this->ArtistaLocalidad->Exportable) $Doc->ExportCaption($this->ArtistaLocalidad);
				if ($this->ArtistaProvincia->Exportable) $Doc->ExportCaption($this->ArtistaProvincia);
				if ($this->ArtistaPais->Exportable) $Doc->ExportCaption($this->ArtistaPais);
				if ($this->ArtistaActivo->Exportable) $Doc->ExportCaption($this->ArtistaActivo);
			} else {
				if ($this->ArtistaId->Exportable) $Doc->ExportCaption($this->ArtistaId);
				if ($this->ArtistaRubro->Exportable) $Doc->ExportCaption($this->ArtistaRubro);
				if ($this->ArtistaSubRubro->Exportable) $Doc->ExportCaption($this->ArtistaSubRubro);
				if ($this->ArtistaNombre->Exportable) $Doc->ExportCaption($this->ArtistaNombre);
				if ($this->ArtistaFoto->Exportable) $Doc->ExportCaption($this->ArtistaFoto);
				if ($this->ArtistaCV->Exportable) $Doc->ExportCaption($this->ArtistaCV);
				if ($this->ArtistaTel->Exportable) $Doc->ExportCaption($this->ArtistaTel);
				if ($this->ArtistaEmail->Exportable) $Doc->ExportCaption($this->ArtistaEmail);
				if ($this->ArtistaFace->Exportable) $Doc->ExportCaption($this->ArtistaFace);
				if ($this->ArtistaWeb->Exportable) $Doc->ExportCaption($this->ArtistaWeb);
				if ($this->ArtistaDireccion->Exportable) $Doc->ExportCaption($this->ArtistaDireccion);
				if ($this->ArtistaLocalidad->Exportable) $Doc->ExportCaption($this->ArtistaLocalidad);
				if ($this->ArtistaProvincia->Exportable) $Doc->ExportCaption($this->ArtistaProvincia);
				if ($this->ArtistaPais->Exportable) $Doc->ExportCaption($this->ArtistaPais);
				if ($this->ArtistaActivo->Exportable) $Doc->ExportCaption($this->ArtistaActivo);
			}
			$Doc->EndExportRow();
		}

		// Move to first record
		$RecCnt = $StartRec - 1;
		if (!$Recordset->EOF) {
			$Recordset->MoveFirst();
			if ($StartRec > 1)
				$Recordset->Move($StartRec - 1);
		}
		while (!$Recordset->EOF && $RecCnt < $StopRec) {
			$RecCnt++;
			if (intval($RecCnt) >= intval($StartRec)) {
				$RowCnt = intval($RecCnt) - intval($StartRec) + 1;

				// Page break
				if ($this->ExportPageBreakCount > 0) {
					if ($RowCnt > 1 && ($RowCnt - 1) % $this->ExportPageBreakCount == 0)
						$Doc->ExportPageBreak();
				}
				$this->LoadListRowValues($Recordset);

				// Render row
				$this->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->ResetAttrs();
				$this->RenderListRow();
				$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled
				if ($ExportPageType == "view") {
					if ($this->ArtistaId->Exportable) $Doc->ExportField($this->ArtistaId);
					if ($this->ArtistaRubro->Exportable) $Doc->ExportField($this->ArtistaRubro);
					if ($this->ArtistaSubRubro->Exportable) $Doc->ExportField($this->ArtistaSubRubro);
					if ($this->ArtistaNombre->Exportable) $Doc->ExportField($this->ArtistaNombre);
					if ($this->ArtistaFoto->Exportable) $Doc->ExportField($this->ArtistaFoto);
					if ($this->ArtistaBio->Exportable) $Doc->ExportField($this->ArtistaBio);
					if ($this->ArtistaCV->Exportable) $Doc->ExportField($this->ArtistaCV);
					if ($this->ArtistaTel->Exportable) $Doc->ExportField($this->ArtistaTel);
					if ($this->ArtistaEmail->Exportable) $Doc->ExportField($this->ArtistaEmail);
					if ($this->ArtistaFace->Exportable) $Doc->ExportField($this->ArtistaFace);
					if ($this->ArtistaWeb->Exportable) $Doc->ExportField($this->ArtistaWeb);
					if ($this->ArtistaDireccion->Exportable) $Doc->ExportField($this->ArtistaDireccion);
					if ($this->ArtistaLocalidad->Exportable) $Doc->ExportField($this->ArtistaLocalidad);
					if ($this->ArtistaProvincia->Exportable) $Doc->ExportField($this->ArtistaProvincia);
					if ($this->ArtistaPais->Exportable) $Doc->ExportField($this->ArtistaPais);
					if ($this->ArtistaActivo->Exportable) $Doc->ExportField($this->ArtistaActivo);
				} else {
					if ($this->ArtistaId->Exportable) $Doc->ExportField($this->ArtistaId);
					if ($this->ArtistaRubro->Exportable) $Doc->ExportField($this->ArtistaRubro);
					if ($this->ArtistaSubRubro->Exportable) $Doc->ExportField($this->ArtistaSubRubro);
					if ($this->ArtistaNombre->Exportable) $Doc->ExportField($this->ArtistaNombre);
					if ($this->ArtistaFoto->Exportable) $Doc->ExportField($this->ArtistaFoto);
					if ($this->ArtistaCV->Exportable) $Doc->ExportField($this->ArtistaCV);
					if ($this->ArtistaTel->Exportable) $Doc->ExportField($this->ArtistaTel);
					if ($this->ArtistaEmail->Exportable) $Doc->ExportField($this->ArtistaEmail);
					if ($this->ArtistaFace->Exportable) $Doc->ExportField($this->ArtistaFace);
					if ($this->ArtistaWeb->Exportable) $Doc->ExportField($this->ArtistaWeb);
					if ($this->ArtistaDireccion->Exportable) $Doc->ExportField($this->ArtistaDireccion);
					if ($this->ArtistaLocalidad->Exportable) $Doc->ExportField($this->ArtistaLocalidad);
					if ($this->ArtistaProvincia->Exportable) $Doc->ExportField($this->ArtistaProvincia);
					if ($this->ArtistaPais->Exportable) $Doc->ExportField($this->ArtistaPais);
					if ($this->ArtistaActivo->Exportable) $Doc->ExportField($this->ArtistaActivo);
				}
				$Doc->EndExportRow();
			}
			$Recordset->MoveNext();
		}
		$Doc->ExportTableFooter();
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here	
	}

	// Recordset Selected event
	function Recordset_Selected(&$rs) {

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

		// Example:
		//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here	
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here	
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Inserting event
	function Row_Inserting($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted($rsold, &$rsnew) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated($rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict($rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}

	// Lookup Selecting event
	function Lookup_Selecting($fld, &$filter) {

		// Enter your code here
	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>); 

	}

	// User ID Filtering event
	function UserID_Filtering(&$filter) {

		// Enter your code here
	}
}
?>
